<script setup lang='ts'>
import { onMounted, ref } from 'vue';
import { useHeaderStore } from '../../../store'
import type { Manga } from '../../../store/index'

const store = useHeaderStore()
const data = ref<Manga>({
    playbill: [],
    hotManga: []
})

onMounted(async () => {
    await store.getData()
    data.value = store.getManga
})
</script>
<template>
    <div class="manga-box">
        <div class="manga-left">
            <div class="playbill-item" v-for="item in data.playbill">
                <img :src="item.img" alt="">
                <div class="name">{{item.name}}</div>
            </div>
        </div>
        <div class="manga-right">
            <div class="title">人气漫画</div>
            <ul class="hotmanga-list">
                <li v-for="(item, index) in data.hotManga"><span class="index"
                        :class="index<3?'no'+(index+1):''">{{index+1}}</span>{{item}}</li>
            </ul>
        </div>
    </div>
</template>
<style lang='less' scoped>
.manga-box {
    display: flex;
    width: 505px;

    .manga-left {
        padding-right: 20px;
        border-right: 1px solid #ccc;
        display: grid;
        gap: 16px;
        grid: 1fr 1fr/1fr 1fr;

        .playbill-item {
            display: flex;
            flex-direction: column;

            img {
                width: 136px;
                height: 77px;
                border-radius: 8px;
                overflow: hidden;
                flex-shrink: 0;
            }

            .name {
                width: 136px;
                font-size: 12px;
                line-height: 17px;
                margin-top: 6px;
                overflow: hidden;
                word-wrap: nowrap;
                text-overflow: ellipsis;
                flex-shrink: 0;
            }
        }
    }

    .manga-right {
        padding-left: 20px;
        flex-shrink: 0;

        .title {
            font-size: 20px;
            line-height: 28px;
            margin-bottom: 10px;
            flex-shrink: 0;
        }

        .hotmanga-list {
            flex-shrink: 0;

            li {
                font-size: 13px;
                line-height: 29px;
                margin-bottom: 2px;

                .index {
                    font-style: italic;
                    font-weight: 700;
                    margin-right: 5px;
                    color: var(--text4);
                }

                .no1 {
                    color: #ff473d !important;
                }

                .no2 {
                    color: #ff6a29;
                }

                .no3 {
                    color: #ff9214;
                }
            }
        }
    }
}
</style>